/* GUI CONVERTED from rspomtb1.p (converter v1.76) Thu Jul 11 01:19:33 2002 */
/* rspomtb1.p - Release Management - Sched Order Maint sub-contract details   */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/* $Revision: 1.8.1.8 $                                                       */
/*V8:ConvertMode=Maintenance                                                  */
/* REVISION: 7.3            CREATED: 03/02/95   by: rxm *G0G5*                */
/* REVISION: 7.3      LAST MODIFIED: 04/25/95   by: bcm *G0L8*                */
/* REVISION: 7.4      LAST MODIFIED: 04/25/95   BY: dpm *H0CX*                */
/* REVISION: 7.3      LAST MODIFIED: 03/21/96   BY: dxk *G1R3*                */
/* REVISION: 8.6      LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan         */
/* REVISION: 8.6E     LAST MODIFIED: 08/04/98   BY: *J2VB* Sandesh Mahagaokar */
/* REVISION: 8.6E     LAST MODIFIED: 08/17/98   BY: *L062* Steve Nugent       */
/* REVISION: 9.1      LAST MODIFIED: 11/17/99   BY: *N04H* Vivek Gogte        */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00   BY: *N08T* Annasaheb Rahane   */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00   BY: *N0KP* Mark Brown         */
/* Old ECO marker removed, but no ECO header exists *F0PN*                    */
/* Revision: 1.8.1.6    BY: Jean Miller        DATE: 05/23/02  ECO: *P074*    */
/* Revision: 1.8.1.7    BY: Kirti Desai        DATE: 06/11/02  ECO: *N1L2*  */
/* $Revision: 1.8.1.8 $   BY: Kirti Desai        DATE: 07/05/02  ECO: *N1NC*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

{mfdeclre.i}
/* EXTERNAL LABEL INCLUDE */
{gplabel.i}

/* SCHEDULED ORDER MAINT SUBPROGRAM FOR SUB-CONTRACT DETAIL */

define input        parameter podsite    like pod_site no-undo.

/* Intentionally name input-output parameters to use the same
   name-space as the pod_det field names.  This allows the shared
   frame to continue to work as well as context-sensitive field
   help.  Leave them undo'able.*/

define input-output parameter pod_wo_lot like pod_wo_lot.
define input-output parameter pod_op     like pod_op.
define input-output parameter subtype    as   character format "x(12)"
   label "Subcontract Type" no-undo.

define shared frame pod1.
define shared variable any_msgs      as  logical.
define shared variable impexp       like mfc_logical             no-undo.
define shared variable impexp_label as   character format "x(8)" no-undo.

{rsordfrm.i}

do with frame pod1:

   display
      pod_wo_lot
      subtype
      pod_op.

   do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

      any_msgs = no.

      set
         pod_wo_lot
         pod_op
         subtype.

      /* VALIDATE subtype AGAINST GENERALIZED CODES */
      if not ({gpcode.v subtype subtype})
      then do:
         {pxmsg.i &MSGNUM=716 &ERRORLEVEL=3}
         /* VALUE MUST EXIST IN GENERALIZED CODES */
         next-prompt
            subtype
            with frame pod1.
         undo,retry.
      end. /* IF NOT ({gpcode.v subtype subtype}) */

      for first wo_mstr
         fields(wo_due_date wo_lot wo_part wo_type wo_status wo_site)
         where wo_lot = pod_wo_lot
         no-lock:
      end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST wo_mstr */

      if not available wo_mstr
      then do:
         /* Work Order/ID does not exist */
         {pxmsg.i &MSGNUM=510 &ERRORLEVEL=3}
         undo, retry.
      end. /* IF NOT AVAILABLE wo_mstr */

      if  wo_type <> ""
      and wo_type <> "c"
      then do:
         /* INVALID ORDER TYPE */
         {pxmsg.i &MSGNUM=5103 &ERRORLEVEL=3 &MSGARG1=wo_type}
         undo, retry.
      end. /* IF wo_type <> "" ... */

      if wo_site <> podsite
      then do:
         /* Work Order site does not match PO line site */
         {pxmsg.i &MSGNUM=5112 &ERRORLEVEL=3 &MSGARG1=wo_site}
         undo, retry.
      end. /* IF wo_site <> podsite */

      if index ("FPC",wo_status) <> 0
      then do:
         /* Work Order ID is closed, planned, or firm planned */
         {pxmsg.i &MSGNUM=523 &ERRORLEVEL=2}
         any_msgs = yes.
      end. /* IF INDEX ("FPC",wo_status) <> 0 */

      if wo_type = "c"
      and wo_due_date < today
      then do:
         /* Cum order has expired */
         {pxmsg.i &MSGNUM=5124 &ERRORLEVEL=2}
         any_msgs = yes.
      end. /* IF wo_type = "c" ... */

      /*GET WO ROUTING RECORD*/
      for first wr_route
         fields(wr_lot wr_op wr_sub_cost)
         where wr_lot = pod_wo_lot
         and   wr_op  = pod_op
         no-lock:
      end. /* FOR FIRST wr_route */

      if not available wr_route
      then do:
         /* Work order operation does not exist */
         {pxmsg.i &MSGNUM=511 &ERRORLEVEL=2}
      end. /* IF NOT AVAILABLE wr_route */

      if wo_type = "c"
      then do:

         /* VALIDATION FOR ADVANCED REPETITIVE */
         for first mfc_ctrl
            fields(mfc_field mfc_logical)
            where mfc_field = "rpc_using_new"
            no-lock:
         end. /* FOR FIRST mfc_ctrl */

         if available mfc_ctrl
         and mfc_logical
         then do:
            /* CHECK FOR SUBCONTRACT COST FOR OPERATION */
            if wr_sub_cost = 0
            then do:
               /* No subcontract cost for this operation */
               {pxmsg.i &MSGNUM=5118 &ERRORLEVEL=2}
               any_msgs = yes.
            end. /* IF wr_sub_cost = 0 */
         end. /* IF AVAILABLE mfc_ctrl */

      end. /* ELSE IF wo_type = "c" THEN DO */

      if any_msgs
      then do:
         message.
         message.
      end. /* IF any_msgs */

   end. /* DO ON ERROR, UNDO */

end. /* DO WITH FRAME pod1 */
